package DTO;

import Main.DataType;

public class Field {

	private String		 _Name;
	private boolean 	 _NotNull;
	private int			 _Type;
	private boolean		 _IsPrimaryKey;
	private ForeignKey   _ForeignKey;
	 
	//Contructor
	public Field(String name, boolean notNull,
			int type, boolean isPrimaryKey, ForeignKey foreignKey )
	{
		this.set_Name(name);
		this.set_NotNull(notNull);
		this.set_Type(type);
		this.set_IsPrimaryKey(isPrimaryKey);
		this.set_ForeignKey(foreignKey);
	}

	public String get_Name() {
		return _Name;
	}

	public void set_Name(String _Name) {
		this._Name = _Name;
	}

	public boolean is_NotNull() {
		return _NotNull;
	}

	public void set_NotNull(boolean _NotNull) {
		this._NotNull = _NotNull;
	}

	public int get_Type() {
		return _Type;
	}

	public void set_Type(int _Type) {
		if(DataType.INT == _Type)
			this._Type = DataType.INT;
		else this._Type = DataType.STRING;
	}

	public boolean is_IsPrimaryKey() {
		return _IsPrimaryKey;
	}

	public void set_IsPrimaryKey(boolean _IsPrimaryKey) {
		this._IsPrimaryKey = _IsPrimaryKey;
	}

	public ForeignKey get_ForeignKey() {
		return _ForeignKey;
	}

	public void set_ForeignKey(ForeignKey _ForeignKey) {
		this._ForeignKey = _ForeignKey;
	}

	public boolean Compare(Field field)
	{
		return(this.get_Name().equals(field.get_Name()) &&
				this.get_Type() == field.get_Type() &&
				this.is_IsPrimaryKey() == field.is_IsPrimaryKey() &&
				this.is_NotNull() == field.is_NotNull()&&
				this.get_ForeignKey().Equal(field.get_ForeignKey()));
	}
	
}
